package com.bobo.base.dialog;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

import androidx.annotation.Nullable;

import com.bobo.base.databinding.DialogLocationServiceBinding;
import com.trello.rxlifecycle3.components.support.RxAppCompatDialogFragment;


/*
 *  @项目名：  boboboom_java
 *  @文件名:   LocationServiceDialog.java
 *  @创建者:   xuwukui
 *  @创建时间:  on 2023/4/4 14:11
 *  @描述：定位服务弹窗
 */
public class LocationServiceDialog extends RxAppCompatDialogFragment {

    private DialogLocationServiceBinding binding;

    private Activity activity;

    public static LocationServiceDialog getNewInstance(Activity context) {
        return new LocationServiceDialog(context);
    }

    public LocationServiceDialog() {

    }

    public LocationServiceDialog(Activity activity) {
        this.activity = activity;
    }

    @Override
    public void onStart() {
        super.onStart();
        Window window = getDialog().getWindow();
        assert window != null;
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        window.setBackgroundDrawable(null);
        window.setGravity(Gravity.CENTER);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DialogLocationServiceBinding.inflate(inflater);

        binding.btnCancel.setOnClickListener(view -> {
            dismiss();
        });

        binding.btnGoSetting.setOnClickListener(view -> {
//            PermissionUtils.gotoLocServiceSettings(activity);
            dismiss();
        });

        return binding.getRoot();
    }

}
